<template>
  <div>
    <el-table :data="noticesList" style="width: 100%">
      <el-table-column fixed prop="id" label="取件编号" width="80"></el-table-column>
      <el-table-column prop="expressCompanyType" label="取件地址类型" width="100"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  methods: {
    //搜索框搜索
    // page() {
    //   const _this=this
    //   axios({
    //     url:'http://39.99.160.25:8088/notices/web/select_notice?keyWord=' +this.keyword,
    //     method:'get',
    //   })
    //   .then(function(res){
    //     console.log(res.data.data)
    //     _this.noticesList=res.data.data.selectdata
    //   })
    // },

    // resetData() {
    //   this.input = {};
    //   this.selectall();
    // },

    handleEdit(row) {
      this.$router.push({
        path: "/updateNotice",
        query: {
          id: row.id
        }
      });
    },

    selectall() {
      const _this = this;
      axios({
        method: "get",
        url: "http://39.99.160.25:8088/express_company/wx/expressCompany_list?page=1&size=10",
        data: {},
        headers: {
              'Authorization': sessionStorage.getItem("token")
        }
      }).then(function(resp) {
        console.log(resp);
        _this.noticesList = resp.data.data.records.lists;
      });
    },
    handleDelete(row) {
      const _this = this;
      console.log(row);
       var qs = require('qs');
      axios({
        method: "delete",
        url:"http://39.99.160.25:8088/express_company/web/deleteExpressCompanyById?id="+row.id,
        // params:{
        //     id:row.id
        // },
       //data: {},
        headers: {
          // "Authorization":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJpZFwiOjksXCJ1c2VybmFtZVwiOm51bGwsXCJwaG9uZVwiOm51bGwsXCJhZGRyZXNzXCI6bnVsbCxcInJlbWFya1wiOm51bGwsXCJhdXRob3JpdHlcIjowLFwicGFzc3dvcmRcIjpcIjExMTExMVwiLFwiaGVhZF9wb3J0cmFpdFwiOm51bGwsXCJhcHBpZFwiOm51bGwsXCJzY29wZVwiOm51bGwsXCJzdGF0ZVwiOm51bGwsXCJ3aGV0aGVyX2RlbGV0ZVwiOm51bGwsXCJpZGVudGl0eV9pZFwiOlwiMTExMTExXCIsXCJjcmVhdGVfdGltZVwiOm51bGwsXCJ1cGRhdGVfdGltZVwiOm51bGwsXCJkZWxldGVfdGltZVwiOm51bGwsXCJvcmRlcnNMaXN0XCI6bnVsbH0iLCJleHAiOjE2MDUwOTU5OTZ9.TBEM_7Ti_Mm_UB9vD236lPstsqMjWAawBaBDFSp6oN0"
          "Authorization":sessionStorage.getItem("token")
        }
      }).then(function(resp) {
        if (resp.data.data.msg == "删除成功") {
          _this.$alert("《" + row.noticeNum + "》删除成功！", "消息", {
            confirmButtonText: "确定",
            callback: action => {
              // _this.$router.push('/notices')
              window.location.reload();
            }
          });
        }
      });
    },

  },
  data() {
    return {
      input: {
        id: "",
        expressCompanyType:"",
      },
      keyword:'',
      noticesList: [
        {
          id: "1",
          expressCompanyType: "111",
        },
        {
          id: "2",
          expressCompanyType: "222",
        },
        {
          id: "3",
          expressCompanyType: "333",
        },
        {
          id: "4",
          expressCompanyType: "444",
        }
      ]
    };
  },
  created() {
    this.selectall();
  }
};
</script>